<?php

/*
 * 原材料修改
 */

namespace Admin\Func;

class Func904020102 {

    var $db;
    var $rst;
    var $errmsg;
    var $MaterialTypeID;
    var $MaterialTypeName;
    var $MaterialTypeDesc;

    public function __construct($MaterialTypeID, $MaterialTypeName, $MaterialTypeDesc) {
        $this->db = new \Think\Model();
        $this->errmsg = '';
        $this->MaterialTypeID = addslashes($MaterialTypeID);
        $this->MaterialTypeName = addslashes($MaterialTypeName);
        $this->MaterialTypeDesc = addslashes($MaterialTypeDesc);
    }

    /*
     * 获取错误信息
     */

    public function getErrMsg() {
        return $this->errmsg;
    }

    /*
     * 验证
     */

    private function validate() {
        $vflag = true;

        return $vflag;
    }

    /*
     * 执行
     */

    public function execute() {
        $vflag = true;
        $OperID = I('OperID');
        if ($this->validate()) {

            $sql = <<<EOD
UPDATE t_lz_ps_materialtype t
SET T.MaterialTypeID = '$this->MaterialTypeID',
T.MaterialTypeName = '$this->MaterialTypeName',
T.MaterialTypeDesc = '$this->MaterialTypeDesc',

T.OperID = '$OperID',
T.OperDate = now()
WHERE T.MaterialTypeID = '$this->MaterialTypeID'

EOD;

            //$this->rst = $this->db->query($sql);
            $this->rst = $this->db->execute($sql);
            if ($this->rst === false) {
                $this->errmsg = $this->db->getDbError();
                $vflag = false;
            } else {
                $vflag = true;
            }
        } else {
            $vflag = false;
        }
        return $vflag;
    }

    public function getRst() {
        return $this->rst;
    }

}
